package com.ywj.collection;

public class ScheduleJobTest {
    public static void main(String[] args) {
        String jobParam1 = "32620-(123,124,125,126),  32619,  32595,  32593";
        String jobParam2 = "32620-(123,124,125,126),  32619-(124),  32595,  32593";
        String jobParam3 = "32619";
        String jobParam4 = "32595,  32593";
        String jobParam5 = "32595,  32593";

        System.out.println(delElement(jobParam1, "32620-(123,124,125,126)"));  //32619,  32595,  32593
        System.out.println(delElement(jobParam1, "32619"));                    //32620-(123,124,125,126),  32595,  32593
        System.out.println(delElement(jobParam1, "32593"));                    //32620-(123,124,125,126),  32619,  32595
        System.out.println("~~~~~");
        System.out.println(delElement(jobParam3, "32619"));
        System.out.println(delElement(jobParam4, "32595"));                    //32593
        System.out.println(delElement(jobParam5, "32593"));                    //32595


    }

    public static String delElement(String input, String element) {
        StringBuilder sb = new StringBuilder();
        boolean firstElement = true;
        for (String s : input.split(",  ")) {
            if (!s.trim().equals(element)) {
                if (!firstElement) {
                    sb.append(",  ");
                }
                sb.append(s.trim());
                firstElement = false;
            }
        }
        String result = sb.toString().trim();
        if (!result.isEmpty() && result.charAt(result.length() -1)==',') {
            result = result.substring(0, result.length() - 2).trim() + ",";
        }
        return result;
    }


//    private static int getData(RBloomFilter<String> bloomFilter, int size) {
//        int count = 0;
//
//    }
}
